#{extends 'EntityViewMaintoExtend.html' /}

#{set title:'Entity - '+ entityName /}

<script type="text/javascript">
$(document).ready(function() {
	 $.getJSON(
				'@{Application.incrementViews()}',
				{
					'id' : '${entityId}',
					'type':'entity'
				},

				function(data) {
					
					document.getElementById('numberofViews').innerHTML = data.res;

				}, 'json') 

});
    
    
    $(function() {
    	$('#renameTopics').hide();
    	$('#entlist').hide();
    	$('#otherTopics').hide();
		if(${isOrgLead} == 0){
			$('#blockIdeaDeveloper').hide();
		}
		
		if(${canLeadOrg == 1}){
			javascript:getOrganizers();
		} else {
			$('#restrictOrganizer').hide();
			$('#input').hide();
		}
	});
    
    var freeze = 0;
    var follow = 0;
    // var a = [document.getElementById("star1"), document.getElementById("star2"), document.getElementById("star3"), document.getElementById("star4"), document.getElementById("star5")]

    function relate(){
    	$('#entlist').fadeIn(1000);
    	$('#r').fadeOut(1000);
    }
    function DelRel(){
		
		$.getJSON('@{Application.removeEntityRelation()}', {
				'entityIdOne': '${entityId}' ,
				'relationName':$("select[id$='deletedRel'] :selected").val()
				},function(data){
					alert(data.box);
							});
							
	}
    function createRel(){
    	
		$.getJSON('@{Application.addRelationtoEntity()}', {
			'firstId': '${entityId}' ,
			'secondName':$("select[id$='mydropdowntopics'] :selected").val(),
			'body':document.getElementById("bodymessage").value,
			'name':document.getElementById("typemsg").value
			},function(data){
				alert(data.res);
						})
	}
    function removeRel(){
		$('#rem').fadeOut(1000);
		$('#otherTopics').fadeIn(1000);
		}
    
    function renameRelation(){
		$('#renameTopics').fadeIn(1000);
		$('#ren').fadeOut(1000);
	}
	function renameRel(){
		
		$.getJSON('@{TopicIdeaController.renameEntityRelation()}', {
			'entityIdOne': '${entityId}' ,
			'relationName':$("select[id$='rename'] :selected").val(),
			'newname':document.getElementById("newName").value
			},function(data){
				alert(data.box);
						});
	}
    
    function mouseonimage(id) {

    	for(var i = 0; i < 5; i++) {
    		a[i].src = "..\\..\\..\\public\\images\\disabledstar.png";
    	}

    	for(var i = 0; i < id; i++) {
    		
    		a[i].src = "..\\..\\..\\public\\images\\redstar.png";
    	}

    }

    function mouseoutimage() {

    	for(var i = 0; i < 5; i++) {
    		a[i].src = "..\\..\\..\\public\\images\\star.png";
    	}

    	for(var i = freeze; i < 5; i++) {

    		a[i].src = "..\\..\\..\\public\\images\\disabledstar.png";
    	}

    }

    /* function resetstars(){

    	for(var i = 0; i < 5; i++) {
    		a[i].src = "..\\..\\..\\public\\images\\disabledstar.png";
    	}

    	freeze = 0;
    } */

    function loadRate(){
    	
    	$.getJSON('@{TopicIdeaController.getEntityRating()}', {'entityId':'${entityId}'},function(data){
    		document.getElementById("currentRating").innerHTML=data.result;

    	});
    	
    	$.getJSON('@{TopicIdeaController.alreadyRatedEntity()}', {'entityId':'${entityId}'},function(data){
    		freeze = data.result;
    		mouseoutimage();

    	});
    	
    }

    function rateEntity(rating) {
    	
    	$.getJSON('@{TopicIdeaController.rateEntity()}', {'rate':rating , 'entityId':'${entityId}'}, function(data) {
    	
    		
    		freeze = data.result;
    		mouseoutimage();
    	});
    	
    	loadRate();
    	
    }
    function displayCreateDiv(){
        $('#createTopics').show();
        document.getElementById('createTopics').focus();

    }

function displayCreateDiv2(topicId,topicTitle,topicDescription){
        $('#draftedTopicsDivDiv').show();
        document.getElementById('drafttopic_title').value=topicTitle;
         document.getElementById('drafttopic_descr').value=topicDescription;
         document.getElementById('draftTopicId').value=topicId;
       document.getElementById('draftedTopicsDivDiv').focus();
    }
    
     function displayCreateDivReq(title, description){
        $('#createTopics').show();
        document.getElementById('topic_title').value = title;
        document.getElementById('topic_descr').value = description;
        document.getElementById('createTopics').focus();
    }

   
    function createpostIdea() {

        if(checkIdeaValidationCreate()){
       var descr=document.getElementById("createDescr").value;
       var title=document.getElementById("createTitle").value;
       $.post("@{TopicIdeaController.createpostIdea()}", {'id':'${entityId}' ,"descr":descr,"title":title ,"whereIdeaExist":"entity"},
  function(data){
 $("<li><a href=@{TopicIdeaController.checkAuthorizationToViewIdea()}?ideaId="+data.ideaId+">"+data.title+"</a></li>")
 .appendTo(document.getElementById("ideas"))
document.getElementById("createTitle").value="";
document.getElementById("createDescr").value="";
document.getElementById("ideatitleexp").innerHTML="Title Required";
document.getElementById("ideadescrexp").innerHTML="Description Required";
$('#newidea').fadeOut(1000);
}, "json");

}
        };


   function draftIdea() {
   if(checkIdeaValidationCreate()){
var descr=document.getElementById("createDescr").value;
var title=document.getElementById("createTitle").value;
       $.post("@{TopicIdeaController.draftIdea()}", {'id':'${entityId}' ,"descr":descr ,'title':title,'whereIdeaExist':"entity"},
  function(data){
$("<li><a id="+"draftIdeaLink"+data.ideaId+" href='javascript:editdraft("+data.ideaId+",\""+data.title+"\",\""+data.description+"\")'>"+data.title+"</a></li>")
   .appendTo(document.getElementById("draftedIdeaList"));
document.getElementById("createTitle").value="";
document.getElementById("createDescr").value="";
document.getElementById("ideatitleexp").innerHTML="Title Required";
document.getElementById("ideadescrexp").innerHTML="Description Required";
$('#newidea').fadeOut(1000);
}, "json");

}
   };

   function slidedown(object) {
       $('#'+document.getElementById(object).id).slideDown();

};


function discard(div){
    if(div=='newIdea'){
 document.getElementById("createTitle").value="";
document.getElementById("createDescr").value="";
document.getElementById("ideatitleexp").innerHTML="Title Required";
document.getElementById("ideadescrexp").innerHTML="Description Required ";
$('#newidea').fadeOut(1000);
    }else{
    document.getElementById("drafttitle").value="";
document.getElementById("draftdescr").value="";
document.getElementById("drafttitleexp").innerHTML="";
document.getElementById("draftdescrexp").innerHTML="";
$('#editDraft').fadeOut(1000);
    }

 }


 function checkIdeaValidationCreate(){
     var title=document.getElementById("createTitle").value;
     var descr=document.getElementById("createDescr").value;
                if(title==null||title==""){
                    document.getElementById("ideatitleexp").innerHTML="Title required"
                }else{
                    if(title.indexOf("&")!=-1){
                         document.getElementById("ideatitleexp").innerHTML="Title can't contain &";
                    }else{
                        if(title.length>25){
                             document.getElementById("ideatitleexp").innerHTML="Title can't be more than 25 letters";
                        }else{
                     document.getElementById("ideatitleexp").innerHTML="" ;
                        }
                }
                }
                if(descr==null||descr==""){
                    document.getElementById("ideadescrexp").innerHTML="Description required"

                }else{
                     if(descr.indexOf("&")!=-1){
                         document.getElementById("ideadescrexp").innerHTML="Description can't contain &";
                    }else{
                     document.getElementById("ideadescrexp").innerHTML="" ;
                }
                }

if(document.getElementById("ideadescrexp").innerHTML=="" && document.getElementById("ideatitleexp").innerHTML==""){
    return true
}
else{
    return false;
}

         }

function editdraft(ideaId,ideaTitle,ideaDescription){
    $('#editDraft').show();
    document.getElementById('editDraft').focus();
    document.getElementById('ideaid').value=ideaId;
              document.getElementById('drafttitle').value=ideaTitle;
              document.getElementById('draftdescr').value= ideaDescription;
               $(document.getElementById("draftIdeaLink"+ideaId)).remove();
}



  function postDraftIdea(ideaId){
               if(checkIdeaValidationDraft()){
              var title=document.getElementById("drafttitle").value;
                  var descr=document.getElementById("draftdescr").value;

                 $.post("@{TopicIdeaController.postDraftIdea()}",
                 {'ideaId':ideaId,'description':descr,'title':title
                      },
  function(data){

$("<li><a href=@{TopicIdeaController.checkAuthorizationToViewIdea()}?ideaId="+data.ideaId+">"+data.ideaTitle+"</a></li>")
 .appendTo(document.getElementById("ideas"))
   document.getElementById('draftdescr').value="";
   document.getElementById('drafttitle').value="";
   document.getElementById('drafttitleexp').innerHTML="";
   document.getElementById('draftdescrexp').innerHTML="";
  $('#editDraft').fadeOut(1000);
  },"json")
            }

           }


 function draftDraftIdea(ideaId){
     if(checkIdeaValidationDraft()){
              var title=document.getElementById("drafttitle").value;
                  var descr=document.getElementById("draftdescr").value;

                 $.post("@{TopicIdeaController.draftDraftIdea()}",
                 {'ideaId':ideaId,'description':descr,'title':title
                      },
  function(data){

$("<li><a id="+"draftIdeaLink"+data.ideaId+" href='javascript:editdraft("+data.ideaId+",\""+data.ideaTitle+"\",\""+data.ideaDescription+"\")'>"+data.ideaTitle+"</a></li>")
   .appendTo(document.getElementById("draftedIdeaList"));
   document.getElementById('draftdescr').value="";
   document.getElementById('drafttitle').value="";
   document.getElementById('drafttitleexp').innerHTML="";
   document.getElementById('draftdescrexp').innerHTML="";
  $('#editDraft').fadeOut(1000);
  },"json")
            }

 }



 function checkIdeaValidationDraft(){
     var title=document.getElementById("drafttitle").value;
     var descr=document.getElementById("draftdescr").value;
                if(title==null||title==""){
                    document.getElementById("drafttitleexp").innerHTML="Title required"
                }else{
                    if(title.indexOf("&")!=-1){
                         document.getElementById("drafttitleexp").innerHTML="Title can't contain &";
                    }else{
                        if(title.length>25){
                             document.getElementById("drafttitleexp").innerHTML="Title can't be more than 25 letters";
                        }else{
                     document.getElementById("drafttitleexp").innerHTML="" ;
                        }
                }
                }
                if(descr==null||descr==""){
                    document.getElementById("draftdescrexp").innerHTML="Description required"

                }else{
                     if(descr.indexOf("&")!=-1){
                         document.getElementById("draftdescrexp").innerHTML="Description can't contain &";
                    }else{
                     document.getElementById("draftdescrexp").innerHTML="" ;
                }
                }

if(document.getElementById("draftdescrexp").innerHTML=="" && document.getElementById("drafttitleexp").innerHTML==""){
    return true
}
else{
    return false;
}

         }


function showDraftedTopicDiv(){

$('#draftedTopicDiv').show();
}

function showDraftedIdeaDiv(){
$('#draftedIdeasDiv').show();
}


</script>

<script type="text/javascript">
	function getOrganizers(entityID) {

		document.getElementById("organizers").innerHTML = "";

		$
				.getJSON(
						'@{Application.getOrganizersEntity()}',
						{
							'entityID' : document.getElementById("entityID").value
						},
						function(data) {
							s = data.res.split("*");
							alert(document.getElementById("entityID").value);
							var total = "<p><label>choose organizer to restrict</label><select id=\"org\">"
							for ( var i = 1; i < s.length; i = i + 1) {
								if (s[i] != "") {
									total += "<option selected value="+i+">"
											+ s[i] + "</option>";
								}
							}
							total += "</select></p>";
							document.getElementById("organizers").innerHTML = total;
						});

	}
	function resOrganizers() {

		var index = document.getElementById("org").selectedIndex
		var organizerName = document.getElementById("org").options[index].text
		var label="";
		var string ="";
		var t="";
		$.getJSON('@{Application.resOrganizersEntity()}', {
			'entityID' : document.getElementById("entityID").value,
			'organizerName' : organizerName
		}, function(data) {
        s=data.res.split("%^%");
		sfirst=s[0];
		spit=sfirst.split("&");
		
		if(spit[0].length>11)
	    {
		  string=spit[0]+"<BR/>";
		}
		if(spit[1].length>11)
		{
			string+="  "+spit[1];
		}
		spitt=s[1].split("&");
		if(spitt[0].length>11)
	    {
		  t=spitt[0]+"<BR/>";
		}
		if(spitt[1].length>11)
		{
			t+="  "+spitt[1];
		}
		if(string.length>0)
		{
			 label+="<label>"+organizerName+" is now restricted to this entity by removing him from organizing the following :<BR/>"+string+"</label><BR/>";
		}
        
        if(t.length>0)
        {
               label+="<BR/><label>"+organizerName+" can not be removed from organizing the following because last organizer on Topic or Entity :<BR/>"+t+"</label>";
       	}
        document.getElementById("label").innerHTML=	label;
		});

	}

	function showDuplicated(){
		if(document.getElementById("duplicatesShown?").value != "duplicatesShown"){
			showDuplicatedIdeas();
			document.getElementById("duplicatesShown?").value = "duplicatesShown";
			$(("#duplicateIdeas")).hide();
			$(("#duplicateIdeas")).slideDown(1000);
		} else {
			$(("#duplicateIdeas")).toggle(1000);
		}
	}

	function showDuplicatedIdeas(){
		var duplications = [];
		var singleDuplicate = [];
		var duplicateIdeasTitles = [];
		var infoOfIdea = [];
		$.getJSON('@{TopicIdeaController.showDuplicateIdeas()}',{'ID':${entityId},'type':'entity'},function(data){
		if(data.box.length != 0){
			duplications = data.box.split("$$");
			for(i = 0; i < duplications.length ; i++){
				singleDuplication = duplications[i].split("*$");
				sourceIdea = singleDuplication[0].split("!id#");
				document.getElementById("duplicateIdeas").innerHTML += "<div  id=\"Duplication"+sourceIdea[1]+"\" > </div><br>";
				document.getElementById("Duplication"+sourceIdea[1]+"").innerHTML += "<a onclick=\"showDuplicates('"+sourceIdea[1]+"')\">" + "Title: "+sourceIdea[0]+"" + "</a><br>";
				document.getElementById("Duplication"+sourceIdea[1]+"").innerHTML += "<a>" + "Description: "+sourceIdea[2]+"" + "</a><br>";
				document.getElementById("Duplication"+sourceIdea[1]+"").innerHTML += "<form id=\"Duplicates"+sourceIdea[1]+"\" style=\"border: 2px solid gray;\"> </form>";
				duplicateIdeasTitles = singleDuplication[1].split("$*");
				var k = 0;
				var duplicateIdeasIDS = [];
				while(k < duplicateIdeasTitles.length){
					infoOfIdea = duplicateIdeasTitles[k].split("!id#");
					//alert("<input type=\"checkbox\" id=\"DuplicateIdea"+(j+1)+"\" value=\""+infoOfIdea[1]+"\" />" + ""+infoOfIdea[0]+"");
					document.getElementById("Duplicates"+sourceIdea[1]+"").innerHTML += "<input type=\"checkbox\" name=\"duplicate\" value=\""+infoOfIdea[1]+"\" />";
					document.getElementById("Duplicates"+sourceIdea[1]+"").innerHTML += "<a  id=\"DuplicateIdea"+infoOfIdea[1]+"\" onclick=\"javascript:toggleDescription('"+infoOfIdea[1]+"')\">" + ""+infoOfIdea[0]+"" + "</a><br>";
					document.getElementById("Duplicates"+sourceIdea[1]+"").innerHTML += "<a  id=\"DuplicateIdeaDescription"+infoOfIdea[1]+"\">" + "Description: "+infoOfIdea[2]+"" + "</a> <br><br>";
					$(("#DuplicateIdeaDescription"+infoOfIdea[1]+"")).hide();
					k ++;
				}
				document.getElementById("Duplicates"+sourceIdea[1]+"").innerHTML += "<input type=\"button\" value=\"Merge with "+sourceIdea[0]+"\" id=\""+"Merge"+sourceIdea[1]+"\" onclick=\"javascript:mergeIdea('"+sourceIdea[1]+"')\" />";
				$(("#Duplicates"+sourceIdea[1]+"")).hide();
			} 
		} else {
			document.getElementById("duplicateIdeas").innerHTML += "<a>  No Duplicate Ideas  </a><br>";
		}
		});
	}

	function toggleDescription(ID){
		$(("#DuplicateIdeaDescription"+ID+"")).toggle(1000);	
	}

	function mergeIdea(ID){
		if(document.getElementById("Duplicates"+ID+"").duplicate.length != null){
		for (var i=0; i < document.getElementById("Duplicates"+ID+"").duplicate.length; i++){
		   if (document.getElementById("Duplicates"+ID+"").duplicate[i].checked){
		      notifyDuplicateOwner(ID, document.getElementById("Duplicates"+ID+"").duplicate[i].value);
			   deleteIdea(document.getElementById("Duplicates"+ID+"").duplicate[i].value);
		    }
	   	}
		} else {
			if(document.getElementById("Duplicates"+ID+"").duplicate.checked){
				//alert(document.getElementById("Duplicates"+ID+"").duplicate.value);
				notifyDuplicateOwner(ID, document.getElementById("Duplicates"+ID+"").duplicate.value);
				deleteIdea(document.getElementById("Duplicates"+ID+"").duplicate.value);
			}
		}
		$.getJSON('@{TopicIdeaController.removeDuplicatesRelation()}',{'ID':ID},function(data){});
		document.getElementById("duplicateIdeas").innerHTML = "";
		window.setTimeout("showDuplicatedIdeas()",100);
	}

	function notifyDuplicateOwner(source, duplicate){
		$.ajax({
			type: "POST",
			url: '@{TopicIdeaController.notifyDuplicateOwner}',
			data: {'id':source, 'id2':duplicate}
			});
	}

	function showDuplicates(id){
		$(("#Duplicates"+id+"")).toggle(1000);
	}

	function deleteIdea(ideaId){

	    $.getJSON('@{TopicIdeaController.deleteIdea()}',{'ideaId':ideaId,'aloneOrNot':"notalone"},function(data){
	        alert(data.x);
	        //if(document.getElementById("bigideadiv"+ideaId)!=null){
	        $(document.getElementById("bigideadiv"+ideaId)).remove();
	        //}

		});

	}

	function deleteIdea(ideaId){

	    $.getJSON('@{TopicIdeaController.deleteIdea()}',{'ideaId':ideaId,'aloneOrNot':"notalone"},function(data){
	        alert(data.x);
	        });
	}
	
	function lockEntity(type){
		
		$.getJSON(
				'@{Application.lockOrUnlockEntity()}',
	{			'entityId' :'${entityId}',
			    'type' : type
			},
			function(data) {
					document.getElementById('result_lock').innerHTML = data.res;
				}, 'json')
			$('#lock_entity').toggle();
			$('#unlock_entity').toggle();
			
		}
</script>
    
<body onLoad="javascript:buttonsChecks()">
	<div id="content">
	<input type="hidden" id="duplicatesShown?" value="duplicatesNotShown" />
		<div id="blockIdeaDeveloper">
			<p>
				<a href="#" onclick="javascript:getMembers();">BlockIdeaDeveloper</a>

                               
			</p>
			<div id="members"></div>
		</div>

		<div id="dividedContentContainer">
		
		
		
			<div id="infoSideBar">
	
				<h5>
					<span>Managers:</span>
				</h5>

				<ul class="blocklist" id="orgManagers">
					#{ifnot managers}
					<p>No Managers yet!</p>
					#{/ifnot} #{list items:managers, as: 'manager' }
					<li><a
						href="@{UserProfile.OtherUserProfile(manager.ideaDeveloper.id)}">${manager.ideaDeveloper.username}</a>
					</li> #{/list}
				</ul>
				
				
				</br>
                <h5><span>Average Rate: </span><span id="currentRating"></span></h5>

				
				<div id="rate">

					<a href="javascript:void(0)"><img id="reset" height="17"
						src="../../../public/images/reset.png" onclick="rateEntity(0)" 
					/></a>  <a href="javascript:void(0)"><img id="star1" height="20"
						src="../../../public/images/disabledstar.png"
						onmouseover="mouseonimage(1)" onmouseout="mouseoutimage()"
						onclick="rateEntity(1)" 
					/></a><a href="javascript:void(0)"><img id="star2" height="20"
						src="../../../public/images/disabledstar.png"
						onmouseover="mouseonimage(2)" onmouseout="mouseoutimage()"
						onclick="rateEntity(2)" 
					/></a><a href="javascript:void(0)"><img id="star3" height="20"
						src="../../../public/images/disabledstar.png"
						onmouseover="mouseonimage(3)" onmouseout="mouseoutimage()"
						onclick="rateEntity(3)" 
					/></a><a href="javascript:void(0)"><img id="star4" height="20"
						src="../../../public/images/disabledstar.png"
						onmouseover="mouseonimage(4)" onmouseout="mouseoutimage()"
						onclick="rateEntity(4)" 
					/></a><a href="javascript:void(0)"><img id="star5" height="20"
						src="../../../public/images/disabledstar.png"
						onmouseover="mouseonimage(5)" onmouseout="mouseoutimage()"
						onclick="rateEntity(5)" 
					/></a>

					<script>
						var a = [ document.getElementById("star1"),
								document.getElementById("star2"),
								document.getElementById("star3"),
								document.getElementById("star4"),
								document.getElementById("star5") ];


						loadRate();

					</script>

				</div>
					
					<br>
					
					
					<input type="submit" id="r" value="Relate Entity" onclick="relate()" />

		<div id="entlist">
			#{ifnot EntitiesNames}



			<p>No Entities in the organization to relate with</p>

			#{/ifnot} #{if EntitiesNames} <select name="mydropdown"
				id="mydropdowntopics"> #{list items:EntitiesNames, as: 'task'
				}
				<option id="" value="${task}">${task}</option> #{/list}
			</select> #{/if}
			<br></br>

			<label for="typemsg" id="tt">Relation Name</label> <input name="typemsg"
			id="typemsg" value="" type="text" /> <br></br>
			
			<label for="bodymessage" id="uu">Description</label>
		<textarea cols="60" rows="7" name="bodymessage" id="bodymessage"></textarea>
			<br></br>
			<input type="submit" id="create" value="Add Relation"
			onclick="createRel()" />
		<br></br>

		</div>
		<input type="submit" id="rem"
			value="Remove Relation with another Entity" onclick="removeRel()" />
			<div id="otherTopics">
			#{ifnot toBeDeleted}



			<p>No Relations to delete !!</p>

			#{/ifnot} #{if toBeDeleted} <select name="mydropdown" id="deletedRel">
				#{list items:toBeDeleted, as: 'task' }
				<option id="" value="${task}">${task}</option> #{/list}
			</select> #{/if}

<br></br>
<input type="submit" id="delrel"
			value="Remove Selected Relation" onclick="DelRel()" />
		</div>
<br></br>
		<input type="submit" id="ren"
				value="Rename Relation" onclick="renameRelation()" />
				<br></br>
		<div id="renameTopics">
			#{ifnot toBeDeleted}

			<p>No Relations to rename !!</p>

			#{/ifnot} #{if toBeDeleted} 
			<label for="newName" id="renamelabel">New Relation Name</label>

		 <input name="typemsg"
			id="newName" value="" type="text" /> 
			<br></br>
			<select name="mydropdown" id="rename">
				#{list items:toBeDeleted, as: 'task' }
				<option id="" value="${task}">${task}</option> #{/list}
			</select> #{/if} 
			<br></br>
			<input type="submit" id="ren"
				value="Rename Selected Relation" onclick="renameRel()" />

		</div>				

			</div>

			
							
			&nbsp;&nbsp; <a href="@{Application.OrganizationView(organization.name)}">${organization.name}</a> 
			#{if parents}
			 > <a href="@{Application.EntityView(parents.id)}">${parents.name}</a>
			
			#{/if}
			
			<div id="infoContainer">
				<h2>${entityName}</h2>
				
			   <h3>#Views: <span id="numberofViews"> </span>  </h3>

				
			</div>
		</div>
		
		
		<div id="borderedContainer">
			<h5>
				<span>Ideas:</span>
			</h5>
			<ul class="blocklist" id="ideas">
				#{ifnot ideas}
				<p>No Ideas avaiable !</p>

				#{/ifnot} #{list items:ideas, as: 'idea' }
				<li><a href="@{TopicIdeaController.checkAuthorizationToViewIdea(idea.id)}">${idea.title}</a></li> 
				#{/list}
					
			</ul>
            <input type="submit" id="createYourOwnIdea" 
			name="createIdea" value="createYourOwnIdea"
			onclick="javascript:slidedown('newidea')" />

		<div id="newidea" style="display: none">
			Idea_Title:<br> <textarea  id="createTitle" name="newIdea"
                                               rows = "2" cols="30 max" style="resize:none" ></textarea> <label id="ideatitleexp">Title Required</label><br />

                        <p></p>
			Idea_Description:<br> <textarea id="createDescr"
                                                    name="newIdea" rows = "3" cols="30 max" ></textarea><label id="ideadescrexp">Description Required</label> <br />
                        <input
				type="submit" name="post" value="post"
				onclick="javascript:createpostIdea()" />
                        <input type="submit"
				name="draft" value="draft" onclick="javascript:draftIdea()" />
                        <input
				type="submit" name="discard" value="discard"
				onclick="javascript:discard('newIdea')" />
		</div>

		</div>
		<div id="borderedContainer">
			<h5>
				<span>Sub Entities:</span>
			</h5>
			<ul class="blocklist" id="Entities">
				#{ifnot subEntites}
				<p>No subEntites avaiable !</p>

				#{/ifnot} 
				#{list items:subEntites, as: 'subEntity' }

				<li><a href="@{Application.EntityView(subEntity.id)}">${subEntity.name}</a></li>
				 #{/list}
			</ul>
		</div>
		<div id="borderedContainer">
			<h5>

					<span>Topics:</span>

		</h5>

        <Button id="createTopicLink" style="display:none " href="#"  onclick="javascript:displayCreateDiv()">CreateTopic</Button>

		<Button id="drafts" style="display: none"
			onclick="javascript:requestTopicDraft(0)">My Drafts</Button>
		<Button id="topReqBtn" class="formbutton" type="submit"
			onclick="javascript:requestTopic()" value="topicReuest"
			name="topicRequest">Request a Topic!</Button>
		<div id="topicrequest" style="display: none">
			<h1>Topic Title:</h1>

			<textarea id="topicTitleReq" cols="20" rows="1"
				style="text-align: left" value="">
                </textarea>
			<h1>Topic Body:</h1>
			<textarea id="topicBodyReq" cols="50" rows="8"
				style="text-align: left" value="">
                </textarea>
			<br> </br>
			<Button class="formbutton" type="submit"
				onclick="javascript:sendReq()" value="send request"
				name="send Request">Send</Button>
			<Button class="formbutton" type="submit"
				onclick="javascript:draftButton()" value="send request"
				name="send Request">Save As Draft</Button>

			<Button class="formbutton" type="submit"
				onclick="javascript:discardButton()" value="send request"
				name="send Request">Discard</Button>
		</div>
		<Button id="topReqchkBtn" class="formbutton" type="submit"
			onclick="javascript:checkTopicReqs(0)">Check Topics Requests
		</Button>
		<div id="requests" style="display: none">No Requests are Here
			now !</div>
		<ul class="Topiclist" id="Topics">
			#{ifnot topics}
			<p>No Topics yet! ,what about requesting one?</p>

			#{/ifnot} #{list items:topics, as: 'topic' }
			<li><a href="@{TopicIdeaController.checkAuthorizationToViewTopic(topic.id)}">${topic.title}</a></li> #{/list}
		</ul>
		
	</div>
			
			
		<div id="borderedContainer">
			<h5>
				<span>Members:</span>
			</h5>

			<ul class="blocklist" id="members">
				#{ifnot memebers}
				<p>No members yet!</p>
				#{/ifnot} #{list items:memebers, as: 'memeber' }
				<li><a href="@{UserProfile.OtherUserProfile(memeber.id)}">${memeber.username}</a>
				</li> 
				#{/list}
					 	
			</ul>
		</div>
	</div>

	<div class="sidebar">
			#{if managers } 
		<P id="result_lock"> </P>
		#{if entityisLocked}
	<a id="unlock_entity" href="#" onClick="javascript:lockEntity('unlock')">unlock Entity</a> 
		
		#{/if}
				#{ifnot entityisLocked}
		
		<a  id="lock_entity" href="#" onClick="javascript:lockEntity('lock')">Lock Entity</a> 
			#{/ifnot}
		#{/if}
		<ul>
			<li>

				<form>
					<input id="follow" class="formbutton" type="button"
						onclick="followEntity()" value="Follow" name="FollowButton" style="background-color:green;">
					<input id="unfollow" class="formbutton" type="button"
						onclick="unfollowEntity()" value="Unfollow" name="UnfollowButton">
					<br> 
					<br>
						<input id="showDuplicatedButton"
				class="formbutton" type="button" value="Duplicated Ideas"
				onclick="javascript:showDuplicated()" style="display:none;"/>
		<br> 
		<br>
		<div id="duplicateIdeas"></div>
                <br>

                 <input id="draftedIdeasButton"
				class="formbutton" type="button" value="show Drafted Idea"
				onclick="javascript:showDraftedIdeaDiv()" />

                <br>
		<br>
		<div id="draftedIdeasDiv" style="display:none">
<ul id="draftedIdeaList">
                    #{if draftedIdeas}
					<h5>
				<span>Drafted Ideas:</span>
			</h5>

					#{list items:draftedIdeas, as: 'draftedIdea' }
				<li><a id="draftIdeaLink${draftedIdea.id}" href="javascript:editdraft('${draftedIdea.id}','${draftedIdea.title}','${draftedIdea.description}')">${draftedIdea.title}</a></li>
				#{/list}
				#{/if}
</ul>
                </div>

 <br>
                <input id="draftedTopicsButton"
				class="formbutton" type="button" value="show Drafted Topics"
				onclick="javascript:showDraftedTopicDiv()" />

                <br>

		<br>
		<div id="draftedTopicDiv" style="display:none">

                    <ul id="draftedTopicList">

                    #{if draftedTopics}
				<h5>
				<span>Drafted Topics:</span>
                                </h5>
				#{list items:draftedTopics, as: 'draftedTopic' }
				<li><a id="draftTopicLink${draftedTopic.id}" href="javascript:displayCreateDiv2('${draftedTopic.id}','${draftedTopic.title}','${draftedTopic.description}')">${draftedTopic.title}</a></li>

				#{/list}
				#{/if}
                                </ul>

                </div>


				</form>
				<h4>
					<span>Followers</span>
				</h4>

				<ul class="blocklist">
					#{ifnot followers}
					<p>No followers yet!</p>
					#{/ifnot} #{list items:followers, as: 'follower' }
					<li><a href="@{UserProfile.OtherUserProfile(follower.id)}">${follower.username}</a>

					</li> #{/list}

				</ul>
			</li>

			<li>
				<h4>Tag Cloud</h4>
				<ul>
					<li>
						<p style="margin: 0;">Creative perfective finance students
							elections code SE ROCKS SO HARD</p>
					</li>
				</ul>

			</li>

			<li>
				<h4>Search</h4>
				<ul>
					<li>
						<form method="get" class="searchform"
							action="http://wpdemo.justfreetemplates.com/">
							<p>
								<input type="text" size="24" value="" name="s" class="s" /> <input
									type="submit" class="searchsubmit formbutton" value="Search" />

							</p>
						</form>
					</li>
				</ul>
			</li>

			<li>
				<h4>Friend List</h4>
				<ul>

					<li><a href="#" title="friend 1"><strong>friend 1</strong>
					</a></li>
					<li><a href="#" title="friend 3"><strong>friend 3</strong>
					</a></li>
					<li><a href="#" title="friend 2"><strong>friend 2</strong>
					</a></li>
				</ul>

			</li>

		</ul>

	</div>
	<div>
		<form name="input" action="#" method="get">

			<a href='#' id="restrictOrganizer" onclick="javascript:resOrganizers()">Restrict
				Organizer</a>
		</form>

	</div>
	<div>
		<div id="organizers"></div>
	</div>
	<div id="label"></div>
	<input id="entityID" type="hidden" value="${entityId}">
	 <div id="editDraft" style="display: none" class="white_content">

			<input type="hidden" id="ideaid" name="ideaId" />

                 Idea_Title : <input type="text"
                            id="drafttitle" name="newIdea" /><label id="drafttitleexp"></label>
                 <br>
             Idea_Description :

             <textarea
                            id="draftdescr" name="newIdea" rows = "3" cols="30 max" ></textarea><label id="draftdescrexp"></label>
                       <br>
                       <br>
                            <input type="submit" name="post"
				value="post"
				onclick="javascript:postDraftIdea(document.getElementById('ideaid').value)" />
			<input type="submit" name="draft" value="draft"
				onclick="javascript:draftDraftIdea(document.getElementById('ideaid').value)" />

			<input type="submit" name="discard" value="discard"
				onclick="discard('editDraft')" />

		</div>
</body>